<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>设置用户</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link rel="stylesheet" href="../js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../style/admin.css" media="all"/>
    <link rel="stylesheet" href="../style/home.css" media="all"/>
    <script src="../js/layui/layui.js"></script>
    <style>

    </style>
</head>
<body layadmin-themealias="default">
<div class="" style="padding: 20px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-card pr20" style=" height: 440px">
            <form class="layui-form" lay-filter="postData" action="" id="postData">
                <input type="hidden" name="id" value="put" th:value="${data.id}"/>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">登录账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="username" placeholder="请输入用户登录账号"
                               autocomplete="off" class="layui-input" required lay-verify="required"
                               th:value="${data.username}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">用户姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="realName" placeholder="请输入用户姓名"
                               autocomplete="off" class="layui-input" required lay-verify="required"
                               th:value="${data.realName}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">用户组</label>
                    <div class="layui-input-block">
                        <input type="text" name="groupName" placeholder="请输入用户组"
                               autocomplete="off" class="layui-input"
                               th:value="${data.groupName}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">所属单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="employer" placeholder="请输入所属单位"
                               autocomplete="off" class="layui-input"
                               th:value="${data.employer}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-block">
                        <input type="text" name="mobileNumber" placeholder="请输入用户手机号"
                               autocomplete="off" class="layui-input" required lay-verify="required"
                               th:value="${data.mobileNumber}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">电子邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" name="email" placeholder="请输入用户电子邮箱"
                               autocomplete="off" class="layui-input"
                               th:value="${data.email}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">登录IP</label>
                    <div class="layui-input-block">
                        <input type="text" name="ip" placeholder="请输入用户登录IP"
                               autocomplete="off" class="layui-input"
                               th:value="${data.ip}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">FTP密码</label>
                    <div class="layui-input-block">
                        <input
                                type="password"
                                name="ftpPwd"
                                placeholder="请输入用户FTP账户密码"
                                autocomplete="off"
                                class="layui-input"
                                th:value="${data.ftpPwd}"
                        />
                    </div>
                </div>


                <div class="layui-col-xs12">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" name="remark" autocomplete="off" class="layui-input"
                               th:value="${data.remark}"
                        />
                    </div>
                </div>
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="postData"
                        id="postBut" style="display: none"
                >
                    保存
                </button>
            </form>
        </div>
    </div>
</div>
<script>
    var callBackReturn = false;
    var index = parent.layer.getFrameIndex(window.name);
    layui.use(['laydate', 'form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();

        form.on('submit(postData)', function (obj) {
            var data = obj.field;
            data["role"] = $("#roleId").find("option:selected").text();
            $.ajax({
                url: './saveUserInfo', //url
                contentType: 'application/json',
                dataType: 'json', //数据格式
                type: 'POST', //请求方式
                async: false, //是否异步请求
                data: JSON.stringify(data),
                success: function (result) {
                    if (result.code == 0) {
                        parent.layer.msg(result.message, {icon: 1});
                        callBackReturn = true;
                        parent.layer.close(index);
                    } else {
                        parent.layer.alert(result.message, {icon: 2});
                    }
                },
            });
            return false;
        });
    });


    function Submit() {
        document.getElementById('postBut').click();
        return callBackReturn;
    }
</script>
<script type="text/javascript" src="../js/lib/watermark.js"></script>
</body>
</html>
